<!--
# Copyright 2015 The Swarming Authors. All rights reserved.
# Use of this source code is governed by the Apache v2.0 license that can be
# found in the LICENSE file.

-->

<!--
@group Swarming Elements

`stats-work-chart' encapsulates a 'google-chart' element and data formating
logic specific for Shards Activity chart of the Swarming statistics app.
This element exposes a 'data' attribute which is a JSON serialized
`google.visualization.DataTable` object and a `resolution` attribute that is
'minutes', 'hours', or 'days'.

Example:
  <stats-work-chart data="{{data_table}}"></stats-work-chart>

@element stats-work-chart
-->

<link rel="import" href="bower_components/polymer/polymer.html">
<link rel="import" href="stats-chart-base.html">

<polymer-element name="stats-work-chart" extends="stats-chart-base" attributes="data resolution isDimension">
  <script>
  Polymer('stats-work-chart', {
    isDimension: false,
    titleText: 'Shards Activity',

    populate: function() {
      this.resetFormattedData();

      // These indexes are relative to stats_gviz._Summary.ORDER.
      this.getKeyFormatter().format(this.dataTable, 0);

      var view = new google.visualization.DataView(this.dataTable);
      if (this.isDimension) {
        view.setColumns([0, 1, 2, 9, 10]);
      } else {
        view.setColumns([0, 3, 4, 11, 12]);
      }

      this.attachView(view);
    }
  });
  </script>
</polymer-element>